Hello all, is it possible to enable or disable menu items dynamically (objetcs context menu / formalPopupMenu)? I found several DXL parts in the DOORS installation folder (especially in "formal.dxl"), but - unfortunately - I don't understand this scripts (especially the first parameter of the "createMenu" or "createItem" function). My current menu will be created with this - simplified - code:
separator();
createMenu (alwaysOn, "MyMenu", null, null);
createItem(alwaysOn, "MySubMenu", 'D', null, null, null ,null, "Test description", null, "C:\\Menus.dxl");
end(menu)
The file with this code is stored in the "formalPopupFiles" folder and the (test)script "Menus.dxl" exists, too. My problem is, that the (Sub)Menu is always enabled (as defined with "alwaysOn") but I need to decide during runtime (e.g module is in exclusive edit mode) if this menu shall be selectable or not. I tried to figure out, how the other menus are created, but all I see is always something like e.g. setExclusiveMap, needsCurrentObject,.., for the first parameter. And these parts are mystical for me. I don't find any implementation for this "code". I played with this parameter and noticed, that this is probably an integer (alwaysOff = 0, alwaysOn = 1, alwaysChecked = 2,...) but when using a function, which delivers - dependet on the current module state - different values (e.g 0 and 1), I'm getting only this error message: -R-E- DXL: <Line:0> incorrect return statement Can anybody help me, how to enable/disable menue items dynamically? Best regards, Michael MichaelBrockhaus - Wed Nov 19 09:44:59 EST 2014 |
Re: How to enable/disable menu items Hi Michael, Did you check the dxl reference manual for createMenu and createItem? Looks like the createItem first parameter is called mappingFunction and would be an integer. They use menuAvailable_ and menuUnavailable_ constants to make is enabled/disabled. Says the mapping functions have to be defined in the file inside $DOORSHOME\lib\dxl\startupfiles and not in the same file as the perms, and so that is probably why you are getting the error message. If you only need to set this when the menu is made, this will work. Have code before creating the menu that determines the state you need (such as is the module in exclusive edit) and have it define the proper integer value to use to create the menu/item command. You may also be able to use some of the standard items to determine availability. For example, I used objDeleteItem to grey out a menu selection when the object is not locked for editing. This covers the case if being in read only mode, or in shareable edit mode but not locked. In this example, I used it to drive the right click menu item. Hope this helps, Greg
|
Re: How to enable/disable menu items GregM_dxler - Thu Nov 20 17:55:18 EST 2014 Hi Michael, Did you check the dxl reference manual for createMenu and createItem? Looks like the createItem first parameter is called mappingFunction and would be an integer. They use menuAvailable_ and menuUnavailable_ constants to make is enabled/disabled. Says the mapping functions have to be defined in the file inside $DOORSHOME\lib\dxl\startupfiles and not in the same file as the perms, and so that is probably why you are getting the error message. If you only need to set this when the menu is made, this will work. Have code before creating the menu that determines the state you need (such as is the module in exclusive edit) and have it define the proper integer value to use to create the menu/item command. You may also be able to use some of the standard items to determine availability. For example, I used objDeleteItem to grey out a menu selection when the object is not locked for editing. This covers the case if being in read only mode, or in shareable edit mode but not locked. In this example, I used it to drive the right click menu item. Hope this helps, Greg
Hi Greg, many thanks! The problem was indeed the missing mapping function in the startupfiles folder. I moved the checking function from the contex menu file into a new DXL file in the startupfiles folder, restartet DOORS and my menu is now dynamic :-) Thank you for your good help. Michael |
Re: How to enable/disable menu items Hi All,
I need to achieve the grey out behaviour. I have created a menu and a sub menu. I need to grey out the sub-menu when the module opens in read only and shareable edit mode. The sub menu must be enabled only when the module opens in exclusive edit mode. I am not able to understand how to use the menuAvailable_ and menuUnavailable_ mapping functions for this. It would be of great help if anyone could provide me the steps in detail. |